from pydantic import BaseModel
import typing as T

from .InnerData import *


class BaseMessageContent(BaseModel):
    type: str


class TextMessageContent(BaseMessageContent):
    type: T.Literal["text"] = "text"
    text: str

    def format(self, **kwargs: T.Dict[str, str]) -> T.Dict[str, str]:
        result = self.model_dump()
        result["text"] = result["text"].format(**kwargs)
        return result


class ImageUrlMessageContent(BaseMessageContent):
    type: T.Literal["image_url"] = "image_url"
    image_url: ImageUrlData


class InputAudioMessageContent(BaseMessageContent):
    type: T.Literal["input_audio"] = "input_audio"
    input_audio: InputAudioData


class VideoUrlMessageContent(BaseMessageContent):
    type: T.Literal["video_url"] = "video_url"
    video_url: VideoUrlData


class VideoMessageContent(BaseMessageContent):
    type: T.Literal["video"] = "video"
    video: T.List[str]


MessageContentTypes = T.Union[
    TextMessageContent,
    ImageUrlMessageContent,
    InputAudioMessageContent,
    VideoUrlMessageContent,
    VideoMessageContent,
]


__all__ = [
    "TextMessageContent",
    "ImageUrlMessageContent",
    "InputAudioMessageContent",
    "VideoUrlMessageContent",
    "VideoMessageContent",
    "MessageContentTypes",
]
